// 格式化时间
export const simpleFormatTime = (time) =>{
    //处理时间格式若为时间戳数字或者字符串转换成毫秒级
    let timestamp 
    if(typeof time === 'number' || (typeof time === 'string' && /^\d+$/.test(time))) {
        //处理时间戳
        timestamp = Number(time).toString().length === 10
        ? Number(time) *1000
        :Number(time)
    }else{
        //处理后返回的标准的时间字符串
        timestamp = new Date(time).getTime()
    }
    //生成Date对象
    const date =new Date(timestamp)
    if(isNaN(date.getTime())) return '时间无效'//返回异常提示\
    //提取年月日时分
    const year =date.getFullYear()
    const month = String(date.getMonth()+1).padStart(2,'0')//月份从0开始 需要+1
    const day =String(date.getDate()).padStart(2,'0')
    const hour =String(date.getHours()).padStart(1,'0')
    const minutes = String(date.getMinutes()).padStart(2,'0')
//拼接成最总格式
return `${year}-${month}-${day}-${hour}-${minutes}`

}


